package Practice.Practice_02.UserManagementSystem;

import java.util.Objects;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        System.out.println("用户管理系统");
        System.out.println("=========================");
        Scanner sc = new Scanner(System.in);
        Person[] person = new Person[20];
        for (int i = 0; i < person.length; i++) {
            if(i == 0){
                person[0] = new Person(0, "admin", "123456", "admin@test.com", "管理员");
            }else{
                person[i] = new Person(-1, "-1", "-1", "-1", "-1");
            }
        }
        while(true){
            System.out.println("用户登录------------------1");
            System.out.println("用户注册------------------2");
            System.out.println("退出程序------------------3");
            int choice = sc.nextInt();
            switch (choice) {
                case 1:
                    System.out.println("用户登录界面");
                    System.out.println("=========================");
                    int index = Login.login(person);
                    if(index == -1){
                        System.out.println("登陆失败。。。");
                        System.out.println("=========================");
                    }else{
                        System.out.println("登录成功。。。");
                        System.out.println("=========================");
                        if(Objects.equals(person[index].getPower(), "管理员")){
                            Admin.adminPage(person,index);
                        }else{
                            User.userPage(person,index);
                        }
                    }
                    break;
                case 2:
                    System.out.println("用户注册界面");
                    System.out.println("=========================");
                    Registration.register(person);
                    break;
                case 3:
                    System.exit(0);
                default:
                    System.out.println("请重新输入！");
            }
        }
    }
}
